#include "stm32f10x.h"                  // Device header
#include "stdint.h"   //声明uint8_t时，要在头文件加上这一行



void Timer_Init(void)
{
	TIM_TimeBaseInitTypeDef TIM_TimeBaseInitstructure;
		NVIC_InitTypeDef NVIC_InitStructure;;
	RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2,ENABLE);
	
	TIM_InternalClockConfig(TIM2);
	
	TIM_TimeBaseInitstructure.TIM_ClockDivision = TIM_CKD_DIV1;
	TIM_TimeBaseInitstructure.TIM_CounterMode =TIM_CounterMode_Up ;
	TIM_TimeBaseInitstructure.TIM_Period = 10000-1;
	TIM_TimeBaseInitstructure.TIM_Prescaler =7200-1;
	TIM_TimeBaseInitstructure.TIM_RepetitionCounter = 0;
	
	TIM_TimeBaseInit(TIM2,&TIM_TimeBaseInitstructure);
	
	TIM_ClearFlag(TIM2,TIM_FLAG_Update);
	
	TIM_ITConfig(TIM2,TIM_IT_Update,ENABLE);
	
	NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);
	

	 NVIC_InitStructure.NVIC_IRQChannel =TIM2_IRQn  ;
	 NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
	 NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 2;
	  NVIC_InitStructure.NVIC_IRQChannelSubPriority =1 ;   //1秒记
	
	NVIC_Init( &NVIC_InitStructure);
	
	 TIM_Cmd(TIM2,ENABLE);
}

//void  TIM2_IRQHandler (void)
//{
//	
//	if(TIM_GetITStatus(TIM2,TIM_IT_Update)==SET)
//	{
//		Num++;
//		TIM_ClearITPendingBit(TIM2,TIM_IT_Update);
//	}
//	
//	
//	
//	
//	
//}

